<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{$pagetitle}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/admin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/admin/style/admin.css" media="all">
    <link rel="stylesheet" href="/static/admin/style/global.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">

        <div class="layui-card-header layuiadmin-card-header-auto" style="padding-bottom: 0px">
            <div>
                <div class="header-left" style="width:40%">
                    <div class="layui-inline">

                    </div>
                </div>
                <div class="header-right search-field" style="width:58%;">

                    <div class="layui-inline">
                        <a class="layui-btn layuiadmin-btn-list" href="{:url('add')}">
                            <i class="layui-icon layui-icon-addition layuiadmin-button-btn"></i> 增加
                        </a>
                    </div>

                </div>
                <div class="clear"></div>
            </div>


        </div>

        <div class="layui-card-body">
            <form class="layui-form" method="get" action="{:url()}" onsubmit="return save_form(this)">
                <table class="layui-table">
                    <colgroup>
                        <col width="150">
                        <col width="150">
                        <col width="200">
                        <col>
                    </colgroup>
                    <thead>
                    <tr>
                        <th width="10%">排序</th>
                        <th width="10%">catid</th>
                        <th>分类名称</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach $data as $key=>$v}
                    <tr>
                        <td style="text-align: center;"><input type='text' name="sort[]" autocomplete="off" style="width:50px;text-align: center;" value="{$v.sort}"><input type='hidden' value="{$v.catid}" name="catid[]"></td>
                        <td style="text-align: center;">{$v.catid}</td>
                        <td class="center">{$v.name}</td>
                        <td class="center">
                            <a href="{:url('update',array('catid'=>$v['catid']))}" class="layui-btn layui-btn-sm" title="修改"><i class="layui-icon">&#xe642;</i></a>
                            <a href="{:url('delete',array('catid'=>$v['catid']))}" class="layui-btn layui-btn-sm ajax_del"><i class="layui-icon">&#xe640;</i></a>
                        </td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
                <div class="layui-inline">
                    <button class="layui-btn layui-btn-sm" onclick="$('.layui-form').attr('action','{:url('sort')}');$('.layui-form').submit();" type="button">排序</button>
                </div>
            </form>
        </div>

    </div>
</div>

<script src="/static/admin/layui/layui.js"></script>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/globals.js"></script>
<script>
    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form'], function () {
        var $ = layui.$
            , admin = layui.admin
            , element = layui.element
            , form = layui.form;
        form.render(null, 'component-form-element');
        element.render('breadcrumb', 'breadcrumb');
        form.on('switch(status)', function (data) {
            var checked = data.elem.checked;
            var status = checked ? 1 : 0;
            var id = data.value;
            ajax_del("{:url('setStatus')}?id=" + id + "&status=" + status, function (msg, data) {
                layer.msg("设置成功");
            });
        });

    });
</script>

</body>
</html>
